{extend name="public:base"}
{block name="body"}
<div class="row">
    <div class="col-md-8">
        <h2 class="text-center">用户登录</h2>
        <div class="container ">
            <form  id="login">
                <div class="form-group row ">
                    <label for="name" class="col-3 col-md-4 col-form-label text-right">用户名:</label>
                    <div class="col-9 col-md-5">
                        <input type="text" class="form-control" id="name" placeholder="请输入用户名" name="name">
                    </div>
                </div>

                <div class="form-group row">
                    <label for="password" class="col-3 col-md-4 col-form-label text-right">密码:</label>
                    <div class="col-9 col-md-5">
                        <input type="password" class="form-control" id="password" placeholder="请输入密码" name="password">
                    </div>
                </div>
                <div class="form-group row ">
                    <div class="col-md-9 text-center">
                        <button type="button" class="btn btn-primary mb-2 ml-4" id="register">登录</button>
                    </div>
                </div>


            </form>
        </div>

    </div>
    <script>
        $(function () {
            $('#register').on('click',function () {
                $.ajax(
                    {
                        type:'post',
                        url:"{:url('index/user/loginCheck')}",
                        data:$('#login').serialize(),
                        datatype:'json',
                        success:function (res) {
                            switch (res.status) {
                                case 1:
                                    alert(res.msg);
                                    window.location.href="{:url('index/index/index')}";
                                    break;
                                case 0:
                                case -1:
                                    alert(res.msg);
                                    break;
                            }
                        }
                    }
                )
            })
        })
    </script>
    {/block}